package base.dao;

import base.bean.RoomEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface IRoomDao extends JpaRepository<RoomEntity,Integer> {

    void deleteById(int id);
    @Modifying
    @Transactional
    @Query(value = "update room u set u.cips = ?1 where u.id = ?2", nativeQuery = true)
    void updateNameById(int cips,int id);

    @Query(value = "select * from room  where cips= 0",nativeQuery = true)
    List<RoomEntity> findByaEquals();

    @Query(value = "select * from room  where cips= 0 and roomtype = ?1", nativeQuery = true)
    List<RoomEntity> findCipsAndRoomtype(String roomytpe);

}
